package function
import TestBibao._

import scala.beans.BeanProperty

object Duiixang {
  //一个scala可以写多个类，默认所有类都是public
  def main(args:Array[String]):Unit={
    //创建对象
    val student=new Student()
    println(student.age)
    println(student.sex)
    student.sex="femele"
    println(student.sex)
  }
}
class Student  {
  var name:String="alice"
  //利用@BeanProperty把变量get和set
  @BeanProperty
  var age:Int=19
  var sex:String="male"
  //构造器测试
//  val student1=new Student1
//  student1.Student1()

}
//定义权限关系
class Persons{
  private var idCord:String="324324"
  var sex:String="female"
  //定义只能在某个包的下面才能访问
  private[function] var age:Int=18

}
//定义构造器
class varStudent1(){
  var name:String=_
  var age:Int=_
  println("1.主构造方法被调用")
  def this(name:String){
    this()
    println("2.辅助构造方法被调用")
    this.name=name
    println(s"name:$name,age:$age")
  }
  def this(name:String,age:Int){
    this(name)
    println("3.辅助构造方法被调用")
    this.age=age
    println(s"name:$name,age:$age")
  }
  def Student1(): Unit ={
    println("一般方法发被调用")
  }
}